
{% load i18n %}
{% load objective_tags %}
{% load markup %}
{% load task_tags %}

{% for objective in objective_list %}
            <div class="objectives">
              <h1>{{ objective.title }}</h1>
	      {% if objective.is_ahead_of_schedule %}
	        <p>This objective is <span class="well-done">ahead</span> of schedule.</p> 
	      {% endif %}
	      {% if objective.is_behind_schedule %}
	        <p>This objective is <span class="warning">behind</span> schedule.</p> 
	      {% endif %}
	      {% if not objective.is_ahead_of_schedule and not objective.is_behind_schedule%}
	        <p>This objective is on schedule.</p> 
	      {% endif %}

	      {{ objective.description|markdown }}

	      <table>
		<tr><th>Aim</th><td><a href="{% url aim_detail object_id=objective.aim.id %}">{{ objective.aim.title }}</a></td></tr>
		<tr><th>Lead</th><td><a href="{% url person_detail object_id=objective.lead.id %}">{{ objective.lead.first_name }} {{ objective.lead.last_name }}</a></td></tr>
		<tr><th>Number of expected deliverables</th><td>{{ objective.quantity }}</td></tr>
		<tr><th>Number of scheduled deliverables</th><td>{{ objective.deliverable_set.count }}</td></tr>
		<tr><th>Expected deliverables to date</th><td>{{ objective.expected_deliverables_to_date }}</td>
		<tr><th>Completed deliverables</th><td>{{ objective.delivered }}</td></tr>
		<tr><th>Overdue deliverables</th><td>{{ objective.overdueDeliverables.count }}</td></tr>
		<tr><th>Start Date</th><td>{{ objective.start_date }}</td></tr>
		<tr><th>End Date</th><td>{{ objective.target_date }}</td></tr>
	      </table>
            </div>

	    <p><a href="{% url objective_edit objective_id=objective.id %}">Edit</a></p>

	    <h2>Incomplete Tasks
	        <a href="{% url objective_task_add objective_id=objective.id%}"><img src="{{ MEDIA_URL }}icons/add.png" alt="Add" title="Add a new task"/></a>
	    </h2>
            {% list_incomplete_tasks objective.task  %}

	    <h2>Incomplete Deliverables
  	        <a href="{% url objective_add_deliverable objective_id=objective.id %}"><img src="{{ MEDIA_URL }}icons/add.png" alt="Add" title="Add a new deliverable"/></a>
            </h2>
	    
            {% list_incomplete_deliverables objective %}
	    
	    <h2>Complete Tasks</h2>
            {% list_complete_tasks objective.task  %}

	    <h2>Delivered</h2>
	    {% list_complete_deliverables objective %}
	    
{% endfor %}